package com.feign.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.feign.consumer.model.User;
import com.feign.consumer.service.HelloService;
import com.feign.consumer.service.RefactorHelloService;

@RestController
public class HelloController {

	@Autowired
	private HelloService helloService;

	@Autowired
	private RefactorHelloService refactorHelloService;

	@RequestMapping(value = "/feign-consumer", method = RequestMethod.GET)
	public String hello() {
		return helloService.hello();
	}

	@RequestMapping(value = "/feign-consumer1", method = RequestMethod.GET)
	public String hello1() {
		StringBuilder sb = new StringBuilder();
		sb.append(helloService.hello("DIDI")).append("/n");
		sb.append(helloService.hello("DIDI", 30)).append("/n");
		sb.append(helloService.hello(new User("DIDI", 20))).append("/n");
		return sb.toString();
	}

	@RequestMapping(value = "/feign-consumer2", method = RequestMethod.GET)
	public String hello2() {
		StringBuilder sb = new StringBuilder();
		sb.append(refactorHelloService.hello("DIDI")).append("/n");
		sb.append(refactorHelloService.hello("DIDI", 30)).append("/n");
		sb.append(refactorHelloService.hello(new com.hello.api.model.User("DIDI", 20))).append("/n");
		return sb.toString();
	}
}
